#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QHBoxLayout>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //创建两个按钮
    QPushButton* button1 = new QPushButton("按钮1");
    QPushButton* button2 = new QPushButton("按钮2");

    //创建水平布局管理器
    QHBoxLayout* layout = new QHBoxLayout();
    //创建space
    QSpacerItem* space = new QSpacerItem(200, 100);

    layout->addWidget(button1);
    layout->addSpacerItem(space);
    layout->addWidget(button2);

    this->setLayout(layout);
}

Widget::~Widget()
{
    delete ui;
}

